var webpack = require('webpack');
var path = require('path');
var node_modules_dir = path.join(__dirname, 'node_modules');
var deps = [
    'react/dist/react.js',
    'react-router/dist/react-router.js',
    'nedb/~/localforage/dist/localforage.js'
];
var materialPath = path.resolve(node_modules_dir, "material-ui/");
var regex= new RegExp(materialPath+".*");

var config = {
    entry: {
        'material':"./app/main.js",
        // 'microbe-client':"./app/main2.js",
        // 'microbe-echarts-client':"./app/main2.js",
    },
    output: {
        // path:"../kejso_micro/src/main/webapp/js",
        // path:"../microbe-spring/web/src/main/resources/static/app",
        path: __dirname+"/app/",
        filename: "[name].js"
    },
    module: {
        noParse: [/material-ui\/.*/],
        loaders: [
			{test: /\.json$/,   loader: "json"},
            { 
                test: /\.js$/, 
                loader: "babel-loader",
                exclude: /node_modules/
            },
            { 
                test: /\.jsx$/, 
                loader: "babel-loader",
                exclude: /node_modules/
            }
        ]
    },
    resolve: {
        modulesDirectories: ["node_modules","packages"],
        alias: {
        }        
    },
    target: 'electron-renderer',
    plugins: [
        // new webpack.optimize.UglifyJsPlugin({
        //     compress: {
        //         warnings: false
        //     }
        // }),
        // new webpack.DefinePlugin({
        //     "process.env": { 
        //         NODE_ENV: JSON.stringify("production") 
        //     }
        // })
    ]
};

deps.forEach(function (dep) {
    var depPath = path.resolve(node_modules_dir, dep);
    config.resolve.alias[dep.split(path.sep)[0]] = depPath;
    config.module.noParse.push(depPath);
});
module.exports=config;
